package main

import "fmt"

func main() {
	ch := make(chan int)
	// channel作为参数时，默认是引用传递
	go producer(ch)
	consumer(ch)
}

func producer(in chan<- int) {
	for i := 1; i <= 10; i++ {
		in <- i
	}
	close(in)
}

func consumer(out <-chan int) {
	for i := range out {
		fmt.Println(i)
	}
}
